define([
    'dojo/_base/declare',
    'esri/layers/GraphicsLayer',
    'esri/geometry/Point',
    'dojo/dom-construct',
], function (declare, GraphicsLayer, Point, DomConstructUtils) {
    var ExGraphicsLayer = declare([GraphicsLayer], {
        _showHighlight: function (mapView, options) {
            /*当不设置标记时，调用下面的方法只设置鼠标样式和高亮效果*/
            var me = this;
            if (!mapView) {
                return;
            }
            me.__mouseOver(mapView, options);
            me.__mouseOut(mapView, options);
        },
        _showLabels: function (mapView, options) {
            var me = this;
            if (!mapView) {
                return;
            }
            var map = mapView.getMap();
            if (!map) {
                return;
            }
            me.labelLayerName = options.layerName + '_label';
            me.labelLayerOptions = {
                layerName: me.labelLayerName,
                data: [],
                options: me.labelOptions.labelSymbol.labelStyle,
                collision: me.labelOptions.collision,
                sr: me.spatialReference,
                onClick: function (e) {
                    if (options.onClick) {
                        options.onClick(e);
                    }
                },
                callback: function (e) {
                    me.labelLayer = e._esriLayer;

                    if (me.labelLayer && !me.labelLayer._init) {
                        me.labelLayer._init = true;
                        me.__mouseOver(mapView, options);
                        me.__mouseOut(mapView, options);
                        me.__extentChange(mapView, options);
                        var scale = map.getScale();
                        if (me._isLayerLoaded(mapView)) {
                            if (me._isAddLabelGraphics(me.labelOptions.scaleInfo, scale)) {
                                me._extentChangeEvt(mapView, options);
                            }
                        }
                        if (typeof me.labelOptions.callback == 'function') {
                            me.labelOptions.callback(e);
                        }
                    }
                },
                onMouseOver: function (e) {
                    me._setCursorPointer(mapView, options);
                },
                onMouseOut: function (e) {
                    me._setCursorDefault(mapView, options);
                },
            };
            mapView.addLayer('customGraphicDivLayer', me.labelLayerOptions);
        },
        _isLayerLoaded: function (mapView) {
            var me = this;
            if (!mapView) {
                return;
            }

            var flag = false;
            var gLayer = mapView.getLayer(me.id);
            if (gLayer && gLayer.visible) {
                flag = true;
            }
            return flag;
        },
        __mouseOver: function (mapView, options) {
            var me = this;
            if (!mapView) {
                return;
            }
            var map = mapView.getMap();
            if (!map) {
                return;
            }
            var scaleInfo = (me.labelOptions && me.labelOptions.scaleInfo) || {};
            if (typeof options.onMouseOver !== 'function') {
                if (me.mouseOver_handle && typeof me.mouseOver_handle.remove == 'function') {
                    me.mouseOver_handle.remove();
                    me.mouseOver_handle = null;
                }
                me.mouseOver_handle = me.on('mouse-over', function (e) {
                    me._setCursorPointer(mapView, options);
                    me._setHighlightSymbol(e, mapView);
                    if (me._isLayerLoaded(mapView)) {
                        var scale = map.getScale();
                        if (!me._isAddLabelGraphics(scaleInfo, scale)) {
                            me._creatLabelData(mapView, [e.graphic]);
                            me._addLabelGraphics(mapView);
                        } else if (e.graphic.__drawn == false) {
                            /*标注自动避让后，文字不加载的，鼠标移入出现文字*/
                            var __divGraphic = e.graphic.__divGraphic;
                            if (__divGraphic) {
                                var _element = __divGraphic._element;
                                if (_element) {
                                    if (!_element._initMargin) {
                                        _element._initMargin = {
                                            marginTop: -parseFloat(_element.style.marginTop) + 'px',
                                            marginLeft:
                                                -parseFloat(_element.style.marginLeft) + 'px',
                                        };
                                    }
                                    _element.style.display = 'block';
                                    _element.style.marginTop = _element._initMargin.marginTop;
                                    _element.style.marginLeft = _element._initMargin.marginLeft;
                                }
                            }
                        }
                        if (me.popupOptions && me.popupOptions.visible) {
                            if (
                                me.popupOptions.scaleInfo &&
                                !me._customPopupContainer.is(':visible')
                            ) {
                                me._customPopupContainer.show();
                                me.isMouse = true;
                                var popupInfos = [Object.assign(e.graphic.attributes)];
                                me.convertSr(mapView, popupInfos, function () {
                                    me.mapView.fire('showCustomPopup', {
                                        data: popupInfos,
                                        isMouse: me.isMouse,
                                    });
                                });
                            }
                        }
                    }
                });
            }
        },
        __mouseOut: function (mapView, options) {
            var me = this;
            if (!mapView) {
                return;
            }
            var map = mapView.getMap();
            if (!map) {
                return;
            }
            var scaleInfo = (me.labelOptions && me.labelOptions.scaleInfo) || {};
            if (typeof options.onMouseOut !== 'function') {
                if (me.mouseOut_handle && typeof me.mouseOut_handle.remove == 'function') {
                    me.mouseOut_handle.remove();
                    me.mouseOut_handle = null;
                }
                me.mouseOut_handle = me.on('mouse-out', function (e) {
                    me._setCursorDefault(mapView, options);
                    me._setDefaultSymbol(e);
                    if (me._isLayerLoaded(mapView)) {
                        var scale = map.getScale();
                        if (!me._isAddLabelGraphics(scaleInfo, scale)) {
                            me._removeLabelGraphics(mapView);
                        } else if (e.graphic.__drawn == false) {
                            var __divGraphic = e.graphic.__divGraphic;
                            if (__divGraphic) {
                                var _element = __divGraphic._element;
                                if (_element) {
                                    _element.style.display = 'none';
                                }
                            }
                        }
                        if (me.popupOptions && me.popupOptions.visible && me.isMouse) {
                            me.isMouse = false;
                            if (e.graphic && e.graphic.attributes && e.graphic.attributes.popupJQ) {
                                e.graphic.attributes.popupJQ.remove();
                                e.graphic.attributes.popupJQ = null;
                            }
                            me.hideCustomPopup();
                        }
                    }
                });
            }
        },
        _setCursorPointer: function (mapView, options = {}) {
            if (!mapView) {
                return;
            }

            var map = mapView.getMap();
            if (!map) {
                return;
            }
            if (typeof options.onClick == 'function') {
                map.setCursor('pointer');
            }
        },
        _setCursorDefault: function (mapView, options = {}) {
            if (!mapView) {
                return;
            }

            var map = mapView.getMap();
            if (!map) {
                return;
            }
            if (typeof options.onClick == 'function') {
                map.setCursor('default');
            }
        },

        /*获取当前范围内的图形要素*/
        _calCurrentGraphics: function () {
            var me = this;
            var graphics = me.graphics;
            me.__currentGraphics = [];
            graphics.map(function (item) {
                if (item._shape) {
                    me.__currentGraphics.push(item);
                }
            });
        },
        _changeSymbol: function (labelClass, mapView) {
            var baseMapLayer = mapView.getBaseMapType();

            if (typeof baseMapLayer == 'string') {
                //baseMapLayer = baseMapLayer.toLocaleLowerCase();
                labelClass += ' ' + baseMapLayer;
            }
            return labelClass;
        },
        _creatLabelData: function (mapView, graphics) {
            var me = this;
            if (!mapView) {
                return;
            }
            var map = mapView.getMap();
            if (!map) {
                return;
            }
            if (!me.labelOptions) {
                return;
            }
            var symbol = me.labelOptions.labelSymbol;

            var labelClass = me._changeSymbol(symbol.labelClass, mapView);

            me.__textGraphics = [];
            graphics.map(function (item) {
                if (item._shape && item.attributes) {
                    var attributes = Object.assign({}, item.attributes);
                    if (attributes && (!attributes.clusterCount || attributes.clusterCount <= 1)) {
                        var label = attributes[me.labelOptions.textField];
                        if (label && label !== '--') {
                            attributes.symbol = attributes.labelSymbol || {
                                html: `<div class="${labelClass}">${label}</div>`,
                            };
                            attributes.__graphic = item;
                            me.__textGraphics.push(attributes);
                        }
                    }
                }
            });
        },
        _addLabelGraphics: function (mapView) {
            var me = this;
            if (!me.labelLayer) {
                me.labelLayer = mapView.getLayer(me.labelLayerName);
            }
            if (me.labelLayer) {
                me.labelLayer.clear();
                me.labelLayerOptions.data = me.__textGraphics;
                me.labelLayerOptions.collision = me.labelOptions.collision;
                me.labelLayer.setData(mapView, {
                    layer: me.labelLayerOptions,
                    _esriLayer: me.labelLayer,
                });
            }
        },
        _removeLabelGraphics: function (mapView) {
            var me = this;
            if (!mapView) {
                return;
            }
            var map = mapView.getMap();
            if (!map) {
                return;
            }

            if (me.__textGraphics && me.__textGraphics.length > 0) {
                if (!me.labelLayer) {
                    me.labelLayer = mapView.getLayer(me.labelLayerName);
                }
                if (me.labelLayer) {
                    me.labelLayer.clear();
                }
                me.__textGraphics = [];
            }
        },
        __extentChange: function (mapView, options) {
            var me = this;
            if (!mapView) {
                return;
            }
            var map = mapView.getMap();
            if (!map) {
                return;
            }
            if (me.zoomEnd_handle && typeof me.zoomEnd_handle.remove == 'function') {
                me.zoomEnd_handle.remove();
                me.zoomEnd_handle = null;
            }

            me.zoomEnd_handle = map.on('zoom-end', function (e) {
                if (me._timeoutChange) {
                    clearTimeout(me._timeoutChange);
                }
                me._timeoutChange = setTimeout(function () {
                    if (me._isLayerLoaded(mapView)) {
                        me._calCurrentGraphics();
                        me._extentChangeEvt(mapView, options);
                    }
                });
            });
            me.panEnd_handle = map.on('pan-end', function (e) {
                if (me._isLayerLoaded(mapView)) {
                    me._calCurrentGraphics();
                    me._extentChangeEvt(mapView, options);
                }
            });
        },
        _extentChangeEvt: function (mapView, options) {
            var me = this;
            if (!mapView) {
                return;
            }
            var map = mapView.getMap();
            if (!map) {
                return;
            }
            mapView.labelCollisionList = [];
            var scaleInfo = me.labelOptions.scaleInfo || {};
            var graphics = me.graphics;
            var scale = map.getScale();
            me._removeLabelGraphics(mapView, options);
            if (me._isAddLabelGraphics(scaleInfo, scale)) {
                me._creatLabelData(mapView, graphics);
                me._addLabelGraphics(mapView);
            }
        },
        _isAddLabelGraphics: function (scaleInfo, scale) {
            var me = this;
            var flag = false;
            if (!me.labelOptions) {
                return;
            }
            if (me.labelOptions.showLabels == 2) {
                flag = true;
            }
            if (me.labelOptions.showLabels == 1) {
                if (scaleInfo.maxScale > 0 && scaleInfo.minScale > 0) {
                    if (scale < scaleInfo.minScale && scale > scaleInfo.maxScale) {
                        flag = true;
                    }
                } else if (scaleInfo.minScale > 0 && scale < scaleInfo.minScale) {
                    flag = true;
                } else if (scaleInfo.maxScale > 0 && scale > scaleInfo.maxScale) {
                    flag = true;
                } else if (!scaleInfo.maxScale && !scaleInfo.minScale) {
                    flag = true;
                }
            }

            if (
                me.__currentGraphics &&
                me.__currentGraphics.length > 0 &&
                me.__currentGraphics.length < me.labelOptions.ptThreshold
            ) {
                flag = true;
            }
            return flag;
        },
        /*鼠标移入后设置高亮样式*/
        _setHighlightSymbol: function (e, mapView) {
            if (!mapView) {
                return;
            }
            var mapUtils = mapView.mapUtils;
            if (!this.highlightOptions || !this.highlightOptions.visible) {
                return;
            }
            var symbol = $.extend(true, {}, e.graphic.symbol);
            if (!e.graphic._defaultSymbol) {
                e.graphic._defaultSymbol = $.extend(true, {}, symbol);
            }
            if (this.highlightOptions.symbol) {
                symbol = mapUtils.createSymbol(mapView, this.highlightOptions.symbol);
            } else {
                if (this.highlightOptions.widthFactor && symbol.width) {
                    symbol.setWidth(symbol.width * this.highlightOptions.widthFactor);
                }
                if (this.highlightOptions.heightFactor && symbol.height) {
                    symbol.setHeight(symbol.height * this.highlightOptions.heightFactor);
                }
                if (this.highlightOptions.sizeFactor && symbol.size) {
                    symbol.setSize(symbol.size * this.highlightOptions.sizeFactor);
                }
                if (this.highlightOptions.color && symbol.color) {
                    symbol.setColor(this.highlightOptions.color);
                }
            }
            e.graphic.setSymbol(symbol);
        },
        /*鼠标移出后还原样式*/
        _setDefaultSymbol: function (e) {
            if (!this.highlightOptions || !this.highlightOptions.visible) {
                return;
            }
            var symbol = $.extend(true, {}, e.graphic._defaultSymbol);
            if (!symbol) {
                return;
            }

            e.graphic.setSymbol(symbol);
        },
        /*打开气泡窗口*/
        openCustomPopup: function (mapView, lngLatArray) {
            var me = this;
            var popupInfos = $.extend(true, [], lngLatArray);
            if (!mapView) {
                return;
            }
            var map = mapView.getMap();
            if (!map) {
                return;
            }
            if (!me._customPopupContainer) {
                me._customPopupContainer = $("<div class='customPopup'></div>").appendTo(
                    mapView.getElement()
                );
            }
            if (!me.popupOptions.isMultiPopup) {
                me._customPopupContainer.empty();
            }
            me.__removeEventHandles();
            me._zoomStartHandle = map.on('zoom-start', function () {
                me.hideCustomPopup();
            });
            me._zoomEndHandle = map.on('zoom-end', function () {
                relocatePopup();
            });
            me._panStartHandle = map.on('pan-start', function () {
                me.hideCustomPopup();
            });
            me._panEndHandle = map.on('pan-end', function () {
                relocatePopup();
            });
            mapView.on('showCustomPopup', function (o) {
                relocatePopup(o);
            });

            popupInit(mapView, popupInfos);

            function popupInit(mapView, popupInfos) {
                me.labelCollisionList = [];
                if (!me.visible) {
                    return;
                }

                setScale();

                me.convertSr(mapView, popupInfos, callback);

                function callback(popupInfos, sr) {
                    if (!me._customPopupContainer.is(':visible')) {
                        return;
                    }
                    for (let i = 0; i < popupInfos.length; i++) {
                        var popupInfo = popupInfos[i];
                        //坐标转换
                        var mapPoint = mapView.mapUtils.createPoint(mapView, popupInfo, { sr: sr });

                        if (isInView(popupInfo)) {
                            var screenPoint = mapView.mapUtils.mapPointToScreen(
                                mapView,
                                mapPoint,
                                {}
                            );
                            popupInfo.screenX = screenPoint.x;
                            popupInfo.screenY = screenPoint.y;
                            loadinfoWindow(popupInfo);
                        }
                    }
                }
            }

            function loadinfoWindow(obj) {
                if (!obj.popupJQ) {
                    var content = '';
                    if ($.isFunction(me.popupOptions.content)) {
                        content = me.popupOptions.content(obj);
                    } else if (obj[me.popupOptions.contentField]) {
                        content = obj[me.popupOptions.contentField];
                    }
                    var popupTemplate = '';
                    if ($.isFunction(me.popupOptions.popupTemplate)) {
                        popupTemplate = me.popupOptions.popupTemplate(obj);
                    } else {
                        var display = me.popupOptions.isShowCloseIcon ? 'block' : 'none';
                        popupTemplate = `<div >
                                                <a class="leaflet-popup-close-button"  href="#" style="display:${display};">×</a>
                                                <div class="leaflet-popup-content-wrapper">
                                                    <div class="leaflet-popup-content" >
                                                    ${content}
                                                    </div>
                                                </div>
                                                <div class="leaflet-popup-tip-container">
                                                    <div class="leaflet-popup-tip"></div>
                                                </div>
                                             </div>`;
                    }

                    var popupJQ = $(popupTemplate).addClass('leaflet-popup');
                    popupJQ.appendTo(me._customPopupContainer);
                    obj.popupJQ = popupJQ;
                }
                //刷新气泡窗口位置
                positionPopUp(obj);

                //气泡窗口关闭事件
                $('.leaflet-popup-close-button', obj.popupJQ)
                    .click(function () {
                        obj.popupJQ.remove();
                        obj.popupJQ = null;
                        obj._remove = true;
                    })
                    .hover(
                        function () {
                            $(this).css('cursor', 'pointer');
                        },
                        function () {
                            $(this).css('cursor', 'default');
                        }
                    );
                var popupContentJQ = $('.leaflet-popup-content-wrapper', obj.popupJQ);
                //if ($.isFunction(me.popupOptions.onClick) || $.isFunction(me.options.onClick)) {
                if ($.isFunction(me.popupOptions.onClick)) {
                    popupContentJQ.hover(
                        function () {
                            $(this).css('cursor', 'pointer');
                        },
                        function () {
                            $(this).css('cursor', 'default');
                        }
                    );
                }

                popupContentJQ.click(function () {
                    if ($.isFunction(me.popupOptions.onClick)) {
                        me.popupOptions.onClick(obj);
                    }
                    // else {
                    //     var graphic = {
                    //         attributes: obj,
                    //         geometry: mapView.mapUtils.createPoint(mapView, obj),
                    //         _layer: me
                    //     };
                    //     me.onClick({
                    //         graphic: graphic,
                    //         getLocation: function () {
                    //             return me.getGraphicLocation(mapView, {graphic: graphic});
                    //         }
                    //     })
                    // }
                    // ;
                });
            }

            //刷新气泡窗口位置
            function positionPopUp(obj) {
                var popupJQ = obj.popupJQ;
                if (!popupJQ || popupJQ.length < 1) {
                    return;
                }

                var width = popupJQ.width();
                var height = popupJQ.height();
                obj.screenX = obj.screenX - width / 2;
                obj.screenY = obj.screenY - height / 2;
                popupJQ
                    .css(
                        'transform',
                        'translate3d(' + obj.screenX + 'px, ' + obj.screenY + 'px, 0)'
                    )
                    .show();
                setCollision(obj);
            }

            //移动泡窗口位置
            function relocatePopup(o = {}) {
                var data = o.data || popupInfos;
                if (!me.visible) {
                    return;
                }
                if (!me._customPopupContainer) {
                    return;
                }
                if (!o.isMouse) {
                    setScale();
                    if (!me._customPopupContainer.is(':visible')) {
                        return;
                    }
                }

                me.labelCollisionList = [];
                for (var i = 0; i < data.length; i++) {
                    var popupInfo = data[i];
                    var mapPoint = mapView.mapUtils.createPoint(mapView, popupInfo);
                    if (isInView(popupInfo) && !popupInfo._remove) {
                        var screenPoint = mapView.mapUtils.mapPointToScreen(mapView, mapPoint, {});
                        popupInfo.screenX = screenPoint.x;
                        popupInfo.screenY = screenPoint.y;
                        if (popupInfo.popupJQ) {
                            positionPopUp(popupInfo);
                        } else {
                            loadinfoWindow(popupInfo);
                        }
                    } else {
                        if (popupInfo.popupJQ) {
                            popupInfo.popupJQ.remove();
                            popupInfo.popupJQ = null;
                        }
                    }
                }
            }

            function isInView(obj) {
                var extent = map.extent;
                if (
                    extent.xmin <= obj.x &&
                    extent.xmax >= obj.x &&
                    extent.ymin <= obj.y &&
                    extent.ymax >= obj.y
                ) {
                    return true;
                } else {
                    return false;
                }
            }

            function setScale() {
                if (!me._customPopupContainer) {
                    return;
                }
                var scale = map.getScale();
                if (!me.popupOptions) {
                    return;
                }
                var scaleInfo = me.popupOptions.scaleInfo;
                if (!scaleInfo && me._customPopupContainer) {
                    me._customPopupContainer.show();
                }

                if (typeof scaleInfo == 'object') {
                    if (scaleInfo.minScale && scaleInfo.maxScale) {
                        if (scale > scaleInfo.minScale || scale < scaleInfo.maxScale) {
                            me._customPopupContainer.hide();
                        } else {
                            me._customPopupContainer.show();
                        }
                    } else if (scaleInfo.minScale > 0) {
                        if (scale > scaleInfo.minScale) {
                            me._customPopupContainer.hide();
                        } else {
                            me._customPopupContainer.show();
                        }
                    } else if (scaleInfo.maxScale > 0) {
                        if (scale < scaleInfo.maxScale) {
                            me._customPopupContainer.hide();
                        } else {
                            me._customPopupContainer.show();
                        }
                    }
                }
            }

            function setCollision(popupInfo) {
                var overlap = false;
                if (!me.popupOptions.collision) {
                    return overlap;
                }

                if (me.labelCollisionList.length > 0) {
                    for (var i = 0; i < me.labelCollisionList.length; i++) {
                        if (
                            me.labelCollisionList[i].popupJQ &&
                            me.labelCollisionList[i].popupJQ.length > 0
                        ) {
                            overlap = isOverlap(
                                me.labelCollisionList[i].popupJQ[0],
                                popupInfo.popupJQ[0]
                            );
                            if (overlap) {
                                popupInfo.popupJQ.hide();
                                break;
                            }
                        }
                    }
                }
                if (!overlap) {
                    popupInfo.popupJQ.show();
                    me.labelCollisionList.push(popupInfo);
                }
                return overlap;
            }

            function isOverlap(node1, node2) {
                var rect1 = node1.getBoundingClientRect();
                var rect2 = node2.getBoundingClientRect();
                var overlap = !(
                    rect1.right < rect2.left ||
                    rect1.left > rect2.right ||
                    rect1.bottom < rect2.top ||
                    rect1.top > rect2.bottom
                );
                return overlap;
            }
        },
        hideCustomPopup: function () {
            if (!this._customPopupContainer) {
                return;
            }
            this._customPopupContainer.hide();
            this._customPopupContainer.children().each(function (index, item) {
                $(item).hide();
            });
        },
        showCustomPopup: function () {
            if (!this._customPopupContainer) {
                return;
            }
            this._customPopupContainer.show();
            this.mapView.fire('showCustomPopup');
        },
        removeCustomPopup: function () {
            if (!this._customPopupContainer) {
                return;
            }
            this._customPopupContainer.remove();
            this._customPopupContainer = null;
        },
        convertSr: function (mapView, lngLatArray, callback) {
            var me = this;
            var mapUtils = mapView.mapUtils;
            var mapSr = mapView.getSpatialReference();
            me.mapSr = mapSr;
            var layerSr = me.spatialReference;
            /*坐标转换，扩展的div不像svg可以自动转换坐标，如果点位的坐标与底图的坐标不一致需要先手工转换坐标*/
            if (mapSr.wkid == '102100') {
                if (layerSr.wkid == '4326' || layerSr.wkid == '4490') {
                    me.lngLatToXY(mapView, lngLatArray, function (lngLatArray) {
                        if ($.isFunction(callback)) {
                            callback(lngLatArray, mapSr);
                        }
                    });
                    return;
                }
            }
            if (mapSr.wkid == '4326' || mapSr.wkid == '4490') {
                if (layerSr.wkid == '102100') {
                    me.xyToLngLat(mapView, lngLatArray, function (lngLatArray) {
                        if ($.isFunction(callback)) {
                            callback(lngLatArray, mapSr);
                        }
                    });
                    return;
                }
            }
            if ($.isFunction(callback)) {
                callback(lngLatArray, me.spatialReference);
            }
        },
        lngLatToXY: function (mapView, lngLatArray, callback) {
            mapView.mapUtils.webMercatorUtils(mapView, lngLatArray, {
                isLngLat: true,
                callback: callback,
            });
        },
        xyToLngLat: function (mapView, data, callback) {
            mapView.mapUtils.webMercatorUtils(mapView, lngLatArray, {
                isLngLat: false,
                callback: callback,
            });
        },
        __removeEventHandles() {
            var me = this;
            var eventHandles = [
                '_zoomStartHandle',
                '_zoomEndHandle',
                '_panStartHandle',
                '_panEndHandle',
            ];
            eventHandles.map(function (item) {
                if (me[item] && $.isFunction(me[item].remove)) {
                    me[item].remove();
                    me[item] = null;
                }
            });
            this.mapView.off('showCustomPopup');
        },
        removeLayer: function (layer, mapView) {
            var me = this;
            if (me.removeCustomPopup) {
                me.removeCustomPopup();
                me.isMouse = false;
            }
            me._removeLabelGraphics(mapView);
            mapView.removeLayer(me.labelLayerName);
        },
        hideLayer: function (mapView) {
            var me = this;
            if (me.hideCustomPopup) {
                me.hideCustomPopup();
            }
            mapView.hideLayer(me.labelLayerName);
        },
        showLayer: function (mapView) {
            var me = this;
            if (me.showCustomPopup) {
                me.showCustomPopup();
            }
            mapView.showLayer(me.labelLayerName);
        },
        _getLayer: function () {
            return this._layer || {};
        },
        _setLayer: function (layer) {
            this._layer = layer;
        },
    });
    return ExGraphicsLayer;
});
